import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.util.Scanner;


public class chatclientUDP {
	public static void main(String[] args) throws IOException{
		DatagramSocket clientSK;
		DatagramPacket clientPK;
		String tinnhan;
		do
		{
			clientSK=new DatagramSocket();
			Scanner input=new Scanner(System.in);
			System.out.println("Client: ");
			tinnhan=input.nextLine();
			clientPK=new DatagramPacket(tinnhan.getBytes(), tinnhan.getBytes().length, InetAddress.getLocalHost(), 8888);
			clientSK.send(clientPK);
			
			byte[]buf=new byte[1024];
			clientPK=new DatagramPacket(buf, buf.length, clientPK.getAddress(), clientPK.getPort());
			clientSK.receive(clientPK);
			input.close();
		}
		while(!tinnhan.trim().equalsIgnoreCase("exit"));
		clientSK.close();
	}
}
